/* tcpnet2h.c - tcpnet2h */

#include "tcp.h"
#include <netinet/in.h>

/*------------------------------------------------------------------------
 *  tcpnet2h -  converter os campos do cabeçalho TCP da Rede (net)
 *  para host byte order
 *------------------------------------------------------------------------
 */
struct tcp* tcpnet2h(struct tcp *ptcp)
{
    /*NOTE: não inclua opções TCP*/
    unsigned short  sport = ptcp->tcp_sport;
    unsigned short  dport = ptcp->tcp_dport;
    unsigned short  window = ptcp->tcp_window;
    unsigned short  urgptr = ptcp->tcp_urgptr;

    tcpseq seq = ptcp->tcp_seq;
    tcpseq ack = ptcp->tcp_ack;

    ptcp->tcp_sport = ntohs(sport);
    ptcp->tcp_dport = ntohs(dport);
    ptcp->tcp_seq = ntohl(seq);
    ptcp->tcp_ack = ntohl(ack);
    ptcp->tcp_window = ntohs(window);
    ptcp->tcp_urgptr = ntohs(urgptr);
    
    return ptcp;
}